{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:15:09.420319Z",
     "start_time": "2024-02-21T02:15:09.415687Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "tuple"
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#内置数据类型\n",
    "#元组tuple\n",
    "my_tuple = 'x', 'y', 'z'\n",
    "type(my_tuple)"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "('x', 'y', 'z')"
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my_tuple"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:15:10.342892Z",
     "start_time": "2024-02-21T02:15:10.337407Z"
    }
   },
   "id": "ef3f137c3f3d9b70",
   "execution_count": 17
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "'x'"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my_tuple[0]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:15:11.245564Z",
     "start_time": "2024-02-21T02:15:11.240011Z"
    }
   },
   "id": "27200b580086397f",
   "execution_count": 18
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(('x', 'y', 'z'), 'abc')\n"
     ]
    }
   ],
   "source": [
    "my_tuple2 = my_tuple, 'abc'\n",
    "print(my_tuple2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:15:17.599185Z",
     "start_time": "2024-02-21T02:15:17.594503Z"
    }
   },
   "id": "5b12d8bd792ffd2b",
   "execution_count": 20
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'tuple' object does not support item assignment",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mTypeError\u001B[0m                                 Traceback (most recent call last)",
      "Cell \u001B[0;32mIn[22], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43mmy_tuple\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;241;43m0\u001B[39;49m\u001B[43m]\u001B[49m \u001B[38;5;241m=\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m123\u001B[39m\u001B[38;5;124m'\u001B[39m\n",
      "\u001B[0;31mTypeError\u001B[0m: 'tuple' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "my_tuple[0] = '123'"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:16:23.595257Z",
     "start_time": "2024-02-21T02:16:23.562093Z"
    }
   },
   "id": "e217fdeddfd32deb",
   "execution_count": 22
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "([1, 2], [4, 5], [6, 7])\n"
     ]
    }
   ],
   "source": [
    "v = ([1,2], [4,5],[6,7])\n",
    "print(v)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:17:30.536308Z",
     "start_time": "2024-02-21T02:17:30.531313Z"
    }
   },
   "id": "3bff25beea99f800",
   "execution_count": 24
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "3"
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(v)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:17:52.322056Z",
     "start_time": "2024-02-21T02:17:52.310131Z"
    }
   },
   "id": "afa47314addfe233",
   "execution_count": 25
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(12345, 54321, 'hello!')\n"
     ]
    }
   ],
   "source": [
    "t = 12345, 54321, 'hello!'\n",
    "print(t)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:20:58.878964Z",
     "start_time": "2024-02-21T02:20:58.874914Z"
    }
   },
   "id": "9426b02058cc73e5",
   "execution_count": 32
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "del t"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:24:07.992423Z",
     "start_time": "2024-02-21T02:24:07.984794Z"
    }
   },
   "id": "32a01f43a592a46b",
   "execution_count": 34
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 't' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mNameError\u001B[0m                                 Traceback (most recent call last)",
      "Cell \u001B[0;32mIn[35], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43mt\u001B[49m\n",
      "\u001B[0;31mNameError\u001B[0m: name 't' is not defined"
     ]
    }
   ],
   "source": [
    "t"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:24:09.877530Z",
     "start_time": "2024-02-21T02:24:09.857218Z"
    }
   },
   "id": "cd95b69c7af32ed3",
   "execution_count": 35
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('x', 'y', 'z', [1, 2], [4, 5], [6, 7])\n"
     ]
    }
   ],
   "source": [
    "new_tuple = my_tuple + v\n",
    "print(new_tuple)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:25:16.737637Z",
     "start_time": "2024-02-21T02:25:16.727553Z"
    }
   },
   "id": "914a6d383e787b43",
   "execution_count": 37
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
